<?php
/**
 * 广告分类新增修改
 * User: hgq
 * Date: 2016/7/11 0008
 * Time: 上午9:35
 */
?>
<script type="application/javascript">

    var to_institution;
    $(function () {

        var to_institution_list =  <?= json_encode($institutions_list) ?>;
        to_institution = $('#to_institution').treeAutocomplete({
            defaultText: '机构',
            source: to_institution_list,
            onSelected: function (element) {
                var to_institution_code = element.getValue();
                $("#edit_institution_code").val(to_institution_code);
            }
        });

        <?php
        if($institution_code != ''){
        ?>
        to_institution.setValue('<?=$institution_code?>');
        <?php
        }
        ?>

    });
</script>
<div>
    <?php
    if ($category != '') {
        ?>
        <form class="form-horizontal adminex-form" role="form">
            <div class="form-group">
                <input type="hidden" id="edit_id" class="form-control" value="<?= $category["id"] ?>" disabled>
                <input type="hidden" id="edit_institution_code" class="form-control"
                       value="<?= $category["institution_code"] ?>" readonly>

                <label class="col-lg-3 col-sm-3 control-label">机构名称：</label>
                <div class="col-lg-9">
                    <input type="text" id="edit_institution_name" class="form-control"
                           value="<?php if ($category["institution_code"] == 0) echo '系统机构'; else echo $category["institution_name"]; ?>"
                           readonly>
                </div>

            </div>
            <div class="form-group">
                <label class="col-lg-3 col-sm-3 control-label">分类名称：</label>
                <div class="col-lg-9">
                    <input type="text" id="edit_name" class="form-control"
                           value="<?= $category["name"] ?>">
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-3 col-sm-3 control-label">分类定义标识符：</label>
                <div class="col-lg-9">
                    <input type="text" id="edit_identifier_code" class="form-control"
                           value="<?= $category["identifier_code"] ?>">
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-3 col-sm-3 control-label">分类描述：</label>
                <div class="col-lg-9">
                <textarea id="edit_description" class="form-control"
                          rows="3"><?= $category["description"] ?></textarea>
                </div>
            </div>
        </form>
        <?php
    } else {
        ?>
        <form class="form-horizontal adminex-form" role="form">

            <div class="form-group">
                <input type="hidden" id="edit_id" class="form-control" value="" disabled>
                <input type="hidden" id="edit_institution_code" class="form-control"
                       value="<?= $institution_code ?>" readonly>

                <label class="col-lg-3 col-sm-3 control-label">机构名称：</label>
                <div class="col-lg-9">
                    <div id="to_institution"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-3 col-sm-3 control-label">分类名称：</label>
                <div class="col-lg-9">
                    <input type="text" id="edit_name" class="form-control" value="">
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-3 col-sm-3 control-label">分类定义标识符：</label>
                <div class="col-lg-9">
                    <input type="text" id="edit_identifier_code" class="form-control" value="">
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-3 col-sm-3 control-label">分类描述：</label>
                <div class="col-lg-9">
                    <textarea id="edit_description" class="form-control" rows="3"></textarea>
                </div>
            </div>
        </form>
        <?php
    }
    ?>
</div>
